<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/views/include/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/views/include/nocachehead.jsp"%>
<title>${attraction.name}</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.raty.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/ratyStar.js"></script>
</head>
<body>
	<%@ include file="/views/include/statusbar.jsp"%>
	<br>
	<br>
	<skyline:setSessionAttrToVar var="SESSION_USER" key="SESSION_USER"/>
	<c:if test="${pageScope.SESSION_USER.id eq attraction.adminId }">
		<c:set var="isAdmin" value="true"/>
	</c:if>
	<div>
		<div>
			<div>
				<div id="Raty_${attraction.id}" title="${attraction.star }">网友评分：</div>
				<div>(已有<span id="voteNum">${attraction.votes }</span>人评价)</div>
			</div>
		</div>
		<div>
			<c:choose>
				<c:when test="${featureList eq NULL}">
					<a>该点还没有特色</a>
				</c:when>
				<c:otherwise>
					<c:forEach var="feature" items="${featureList}" begin="0" end="6" step="1">
						<div>
							<a href="${pageContext.request.contextPath}/attraction/feature/${feature.id}.html">
								<img alt="${feature.title }" title="${feature.title }" src="${pageContext.request.contextPath}/image/${feature.portrait}">
							</a> 
							<span><c:out value="${feature.title}" /></span>
						</div>
					</c:forEach>
				</c:otherwise>
			</c:choose>
			<c:if test="${not empty pageScope.SESSION_USER }">
				<a style="color: #0099CC" href="${pageContext.request.contextPath}/attraction/feature/add/${attraction.id}.html">我要添加</a>
			</c:if>
		</div>
		<div>
			<div>游记和图集</div>
			<c:if test="${empty type }">
				<a>全部</a>
				<a href="${pageContext.request.contextPath}/attraction/view/${attraction.id}.html?type=TRAVELNOTE">游记</a>
				<a href="${pageContext.request.contextPath}/attraction/view/${attraction.id}.html?type=ALBUM">图集</a>
			</c:if>
			<c:if test="${type eq 'ALBUM' }">
				<a href="${pageContext.request.contextPath}/attraction/view/${attraction.id}.html">全部</a>
				<a href="${pageContext.request.contextPath}/attraction/view/${attraction.id}.html?type=TRAVELNOTE">游记</a>
				<a>图集</a>
			</c:if>
			<c:if test="${type eq 'TRAVELNOTE' }">
				<a href="${pageContext.request.contextPath}/attraction/view/${attraction.id}.html">全部</a>
				<a>游记</a>
				<a href="${pageContext.request.contextPath}/attraction/view/${attraction.id}.html?type=ALBUM">图集</a>
			</c:if>
			
			<c:forEach var="ref" items="${refList}" begin="0" end="6" step="1">
				<c:if test="${ref.refType eq 'ALBUM' }">
					<div>
						<div>
							<a title=" ${ref.refTitle }" href="${pageContext.request.contextPath}/attraction/ref/${ref.id}.html">
								<img alt="${ref.refTitle}" src="${pageContext.request.contextPath}/image/${ref.refPortrait}" />
							</a>
						</div>
						<div>
							<c:out value="${ref.refTitle }" />
						</div>
					</div>
				</c:if>
				<c:if test="${ref.refType eq 'TRAVELNOTE' }">
					<div>
						<div>
							<a title="${ref.refTitle }" href="${pageContext.request.contextPath}/attraction/ref/${ref.id}.html">
								<c:out value="${ref.refTitle }" />
							</a>
						</div>
						<div>
							<p><skyline:summary length="60" value="${ref.refDigest }" /></p>
							<p>
								<a title="${ref.refTitle }" href="${pageContext.request.contextPath}/attraction/ref/${ref.id}.html">
								查看游记
								</a>
							</p>
						</div>
					</div>
				</c:if>
			</c:forEach>
			<div>
				<a href="${pageContext.request.contextPath}/attraction/ref/list/${attraction.id}.html?type=${type}">more</a>
			</div>
			
			<div>
				<c:if test="${empty type and isAdmin}">
					<a href="${pageContext.request.contextPath}/attraction/ref/${attraction.id}/photo/upload.html?">快速上传</a>
					<a href="${pageContext.request.contextPath}/attraction/ref/add/${attraction.id}.html?type=TRAVELNOTE">投寄日志</a>
					<a href="${pageContext.request.contextPath}/attraction/ref/add/${attraction.id}.html?type=ALBUM">投寄相册</a>
				</c:if>
				<c:if test="${type eq 'ALBUM' and isAdmin }">
					<a href="${pageContext.request.contextPath}/attraction/ref/${attraction.id}/photo/upload.html?">快速上传</a>
					<a href="${pageContext.request.contextPath}/attraction/ref/add/${attraction.id}.html?type=ALBUM">投寄相册</a>
				</c:if>
				<c:if test="${type eq 'TRAVELNOTE' and isAdmin }">
					<a href="${pageContext.request.contextPath}/attraction/ref/add/${attraction.id}.html?type=TRAVELNOTE">投寄日志</a>
				</c:if>
			</div>
		</div>
		<div>
		<%--
			<skyline:comment maxSize="10" commentType="ATTRACTION" objId="comment" contextPath="${pageContext.request.contextPath}"
				resourceId="${attraction.id }" resourceName="${attraction.name }" ownerId="${attraction.adminId}" />
		--%>
		</div>
	</div>
	<div>
		<div>
			<span>${attraction.name}</span>
			<span>位置：</span>
			<a href="${pageContext.request.contextPath}/attraction/list.html?siteType=COUNTRY&siteId=${attraction.siteId}">${attraction.country}</a>
			<em>&gt;</em>
			<a href="${pageContext.request.contextPath}/attraction/list.html?siteType=PROVINCE&siteId=${attraction.siteId}">${attraction.province}</a>
			<em>&gt;</em>
			<a href="${pageContext.request.contextPath}/attraction/list.html?siteType=CITY&siteId=${attraction.siteId}">${attraction.city}</a>
			<em>&gt;</em>
			<a>${attraction.detailAddress}</a>
			<c:if test="${isAdmin }">
				<a id="edit" href="${pageContext.request.contextPath}/attraction/edit/${attraction.id}.html">编辑</a>
			</c:if>
		</div>
		<div>
			<img title="${attraction.name}" src="${pageContext.request.contextPath}/image/${attraction.portrait}" />
		</div>
		
		<c:set var="redirectUrl" value="${pageContext.request.contextPath}/attraction/view/${attraction.id}.html?type=${type }" />
		<c:if test="${empty pageScope.SESSION_USER }">
			<a href="${pageContext.request.contextPath}/login.html?requestFrom=${redirectUrl }">关注TA</a>
		</c:if>
		<c:if test="${not empty pageScope.SESSION_USER and not isAdmin}">
			<div id="follow" <c:if test="${requestScope.isIdol and not isAdmin}">style="display:none"</c:if> >
				<a href="#" onclick="Follow.follow('${attraction.id }','${attraction.name }','${attraction.portrait }','ATTRACTION',this,followedOk,'${redirectUrl }');">关注TA</a>
			</div>
			<div id="unfollow" <c:if test="${not requestScope.isIdol and not isAdmin}">style="display:none"</c:if> >
				<a href="#" onclick="Follow.unfollow('${attraction.id }','ATTRACTION',this,unfollowedOk,'${redirectUrl }');">取消关注</a>
			</div>
			<script type="text/javascript">
				function followedOk(input) {
					$('#unfollow').show();
					$('#follow').hide();
				}
				function unfollowedOk(input) {
					$('#follow').show();
					$('#unfollow').hide();
				}
			</script>
		</c:if>
		
		<div>
			地主：
			<a href="${pageContext.request.contextPath}/wo/${attraction.adminId}.html">
				<img alt="${attraction.adminNickname }" title="${attraction.adminNickname }" src="${pageContext.request.contextPath}/image/${attraction.adminPortrait}" />
			</a>
		</div>
		<div>
			简介：<c:out value="${attraction.introduction }" />
		</div>
		<div>
			粉丝：
			<c:forEach var="fans" items="${fanList}" begin="0" end="6" step="1">
				<a href="${pageContext.request.contextPath}/wo/${fans.fanId}.html">
					<img alt="${fans.fanNickname }" title="${fans.fanNickname }" src="${pageContext.request.contextPath}/image/${fans.fanPortrait }">
				</a>
			</c:forEach>
			<c:if test="${fn:length(fanList) > 6}">
				<a href="${pageContext.request.contextPath}/fans/${attraction.id}.html">more</a>
			</c:if>
		</div>
	</div>
	
	
	<script type="text/javascript">
		(function($){
			$(document).ready(function(){
				var ratyReadOnly = true;
				<c:if test="${not empty pageScope.SESSION_USER }">
				ratyReadOnly = false;
				</c:if>
				$("div[id^=Raty_]").each(function(){
					var This = this;
					var targetId = this.id.substring(5);
					var setting = {
						width:'200px',
						targetId:targetId,
						targetObj:This,
						targetType:'ATTRACTION',
						readOnly:ratyReadOnly,
						start:$(This).attr('title'),
						numId:'voteNum'
					};
					Raty.init(setting);
				});
			});
		})(jQuery);
	</script>
</body>
</html>